-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix circular dependency in wpcom-xhr-wrapper
#42785
Conversation
`lib/wpcom-xhr-wrapper` was introducing a circular dependency through `lib/user/utils`: ``` client/lib/user/utils.js -> client/lib/user/index.js -> client/lib/user/user.js -> client/lib/user/support-user-interop.js -> client/lib/wp/browser.js -> client/lib/wpcom-xhr-wrapper/index.js -> client/lib/user/utils.js ``` Since `lib/wpcom-xhr-wrapper` is all async anyway, we can load `lib/user/utils` dynamically, and avoid the circular dependency.
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Webpack Runtime (~88 bytes added 📈 [gzipped])
Webpack runtime for loading modules. It is included in the HTML page as an inline script. Is downloaded and parsed every time the app is loaded. App Entrypoints (~9066 bytes removed 📉 [gzipped])
Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used. Sections (~9667 bytes added 📈 [gzipped])
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can confirm Jetpack cloud still works great! LGTM
Thank you, @cbauerman! 🙇 |
lib/wpcom-xhr-wrapper
was introducing a circular dependency forlib/user/utils
:Since
lib/wpcom-xhr-wrapper
is all async anyway, we can loadlib/user/utils
dynamically, and avoid the circular dependency.@cbauerman: Please ensure that Jetpack Cloud continues to work correctly with these changes.
Changes proposed in this Pull Request
lib/user/utils
dynamically inlib/wpcom-xhr-wrapper
, instead of using a synchronousrequire
(which we shouldn't be using in client code anyway).Testing instructions
Ensure any code making use of
lib/wpcom-xhr-wrapper
, such as Jetpack Cloud, continues to work correctly. I believe everything is working, but I've only been able to perform very minimal testing.